# -*- coding: utf-8 -*-
# @Author : HaleShi
# @Time : 2023-05-22
# @File : 4.排序.py

data_dict = {
    "aid": "431518958",
    "auto_play": "2",
    "build": "6240300",
    "cid": "862033117",
    "did": "xx",
    "epid": "",
    "from_spmid": "tm.recommend.0.0",
    "ftime": "1679394916",
    "lv": "0",
    "mid": "0",
    "mobi_app": "android",
    "part": "0",
    "sid": "0",
    "spmid": "tm.recommend.0.0",
    "stime": "1679404453",
    "sub_type": "0",
    "type": "3",
}

# 根据键排序
ordered_string = "&".join(["{}={}".format(key, data_dict[key]) for key in sorted(data_dict.keys())])

print(ordered_string)